package cs2114.antiFingerMines;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;

// -------------------------------------------------------------------------
/**
 *  This activity is the main activity called when the app is first created
 *  creating the main menu
 *
 * @author Blake Whaley
 * @author Graham McLaughlin (gjm1324)
 * @author William Vuong (wnvuong)
 * @version 2012.29.4
 */
public class AntiFingerMinesMenu extends Activity
{
    private static final int RESULT_CLOSE_ALL = 1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button EasyGame = (Button)findViewById(R.id.EasyGame);
        EasyGame.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v)
            {
                Intent EasyGameIntent = new Intent(AntiFingerMinesMenu.this,
                    AntiFingerMinesEasy.class);
                startActivityForResult(EasyGameIntent, 1);
            }
        });

        Button MediumGame = (Button)findViewById(R.id.MediumGame);
        MediumGame.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent MediumGameIntent = new Intent(AntiFingerMinesMenu.this,
                    AntiFingerMinesMedium.class);
                startActivityForResult(MediumGameIntent, 1);
            }
        });

        Button HardGame = (Button)findViewById(R.id.HardGame);
        HardGame.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent HardGameIntent = new Intent(AntiFingerMinesMenu.this,
                    AntiFingerMinesHard.class);
                startActivityForResult(HardGameIntent, 1);
            }
        });

        Button QuitGame = (Button)findViewById(R.id.Quit);
        QuitGame.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                AntiFingerMinesMenu.this.finish();
                AntiFingerMinesMenu.this.moveTaskToBack(true);
            }
        });
    }

    /**
     * This method is used to ensure that the quit buttons will
     * close all activities and their child activities so a user
     * can actually quit the application
     */
    @Override
    protected void onActivityResult(int requestCode, int resultCode,
        Intent data)
    {
        switch(resultCode)
        {
        case RESULT_CLOSE_ALL:
            setResult(RESULT_CLOSE_ALL);
            finish();
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
}
